package com.lanou3g.hw0517.view;


import com.lanou3g.hw0517.commons.Constant;
import com.lanou3g.hw0517.pojo.User;
import com.lanou3g.hw0517.util.JDBCUtil;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
import java.io.IOException;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.List;


@WebServlet(name = "searchServlet", urlPatterns = "/s")
public class searchServlet extends HttpServlet {

    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        response.setContentType("text/html;charset=utf8");

//        List<String> list=new ArrayList<String>();
        HttpSession session = request.getSession();

        User user = (User) session.getAttribute(Constant.Session.USER);

        if (user.getUsername() != null) {
            request.getRequestDispatcher("/result").forward(request, response);
        }else {
            request.getRequestDispatcher("/login.jsp").forward(request, response);
        }

    }

    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        this.doPost(request, response);
    }
}
